package com.duobaoyu.dby.supply.message.listener.hander.task;

import com.duobaoyu.dby.resource.remote.common.constant.ResourceMessageConstant;
import com.duobaoyu.dby.supply.biz.client.resource.ResourceTaskAsyncAdminClient;
import com.duobaoyu.dby.supply.core.dinger.annotation.DingerTalk;
import com.duobaoyu.dby.supply.core.rocketmq.handler.AbstractClusterMessageHandler;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.message.MessageExt;
import org.springframework.stereotype.Component;

/**
 * 异步任务消息handler
 * @Author yangyong
 * @Date 2023/10/20
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class AsyncTaskMessageHandler extends AbstractClusterMessageHandler<Long>{
	private final ResourceTaskAsyncAdminClient resourceTaskAsyncAdminClient;

	@Override
	@DingerTalk(title = "供应链异步任务处理Consumer")
	public boolean messageHandler(Long id, MessageExt messageExt) {
		if(log.isDebugEnabled()) {
			log.debug("异步任务消息处理中任务ID:{}...", id);
		}
		resourceTaskAsyncAdminClient.asyncTaskHandler(id);
		return Boolean.TRUE;
	}

	@Override
	public String getTopic() {
		return ResourceMessageConstant.AsyncTaskTopic.TOPIC;
	}

	@Override
	public String getTag() {
		return ResourceMessageConstant.AsyncTaskTopic.NEW_SUPPLY_CHAIN_TAG;
	}
}
